﻿using System;
using UnityEngine;

namespace Sizebox.CharacterEditor
{
	// Token: 0x02000253 RID: 595
	[Serializable]
	public struct MaterialData
	{
		// Token: 0x06000CE6 RID: 3302 RVA: 0x00067E34 File Offset: 0x00066034
		public MaterialData(MaterialWrapper wrapper)
		{
			this.id = wrapper.Id;
			Material material = wrapper.Material;
			if (material.shader)
			{
				this.shaderName = material.shader.name;
			}
			else
			{
				this.shaderName = string.Empty;
			}
			if (material.HasProperty("_Color"))
			{
				this.mainColor = material.GetColor("_Color");
			}
			else
			{
				this.mainColor = Color.clear;
			}
			if (material.HasProperty("_Ambient"))
			{
				this.ambientColor = material.GetColor("_Ambient");
			}
			else
			{
				this.ambientColor = Color.clear;
			}
			if (material.HasProperty("_Specular"))
			{
				this.specularColor = material.GetColor("_Specular");
			}
			else
			{
				this.specularColor = Color.clear;
			}
			if (material.HasProperty("_EmissionColor"))
			{
				this.emissionColor = material.GetColor("_EmissionColor");
			}
			else
			{
				this.emissionColor = Color.clear;
			}
			this.renderMode = wrapper.RenderMode;
			if (material.HasProperty("_Cutoff"))
			{
				this.alphaCutoff = material.GetFloat("_Cutoff");
			}
			else
			{
				this.alphaCutoff = 0.5f;
			}
			if (material.HasProperty("_METALLIC"))
			{
				this.metallic = material.GetFloat("_METALLIC");
			}
			else
			{
				this.metallic = 0f;
			}
			if (material.HasProperty("_Glossiness"))
			{
				this.smoothness = material.GetFloat("_Glossiness");
			}
			else
			{
				this.smoothness = 0f;
			}
			if (material.HasProperty("_DetailAlbedoMap"))
			{
				this.detailNormalMapIndex = wrapper.DetailNormalMap;
				this.detailTiling = material.GetTextureScale("_DetailAlbedoMap");
			}
			else
			{
				this.detailNormalMapIndex = 0;
				this.detailTiling = Vector2.one;
			}
			if (material.HasProperty("_ShadowLum"))
			{
				this.shadowLum = material.GetFloat("_ShadowLum");
			}
			else
			{
				this.shadowLum = 0f;
			}
			if (material.HasProperty("_AmbientRate"))
			{
				this.ambientRate = material.GetFloat("_AmbientRate");
			}
			else
			{
				this.ambientRate = 0f;
			}
			this.removeTexture = wrapper.RemoveTexture;
			this.useEmission = wrapper.UseEmission;
		}

		// Token: 0x06000CE7 RID: 3303 RVA: 0x000680A8 File Offset: 0x000662A8
		public void LoadMaterialData(MaterialWrapper wrapper)
		{
			Material material = wrapper.Material;
			Shader shader = Shader.Find(this.shaderName);
			if (shader)
			{
				material.shader = shader;
			}
			if (material.HasProperty("_Color"))
			{
				material.SetColor("_Color", this.mainColor);
			}
			if (material.HasProperty("_Ambient"))
			{
				material.SetColor("_Ambient", this.ambientColor);
			}
			if (material.HasProperty("_Specular"))
			{
				material.SetColor("_Specular", this.specularColor);
			}
			if (material.HasProperty("_EmissionColor"))
			{
				material.SetColor("_EmissionColor", this.emissionColor);
			}
			wrapper.RenderMode = this.renderMode;
			if (material.HasProperty("_Cutoff"))
			{
				material.SetFloat("_Cutoff", this.alphaCutoff);
			}
			if (material.HasProperty("_METALLIC"))
			{
				material.SetFloat("_METALLIC", this.metallic);
			}
			if (material.HasProperty("_Glossiness"))
			{
				material.SetFloat("_Glossiness", this.smoothness);
			}
			if (material.HasProperty("_DetailAlbedoMap"))
			{
				wrapper.SetDetailNormalMap(this.detailNormalMapIndex);
				material.SetTextureScale("_DetailAlbedoMap", this.detailTiling);
			}
			if (material.HasProperty("_ShadowLum"))
			{
				material.SetFloat("_ShadowLum", this.shadowLum);
			}
			if (material.HasProperty("_AmbientRate"))
			{
				material.SetFloat("_AmbientRate", this.ambientRate);
			}
			wrapper.RemoveTexture = this.removeTexture;
			wrapper.UseEmission = this.useEmission;
		}

		// Token: 0x06000CE8 RID: 3304 RVA: 0x00068254 File Offset: 0x00066454
		public static bool operator ==(MaterialData data, MaterialData data2)
		{
			return data.shaderName.Equals(data2.shaderName) && !(data.mainColor != data2.mainColor) && !(data.ambientColor != data2.ambientColor) && !(data.specularColor != data2.specularColor) && !(data.emissionColor != data2.emissionColor) && data.smoothness == data2.smoothness && data.metallic == data2.metallic && data.renderMode == data2.renderMode && data.alphaCutoff == data2.alphaCutoff && data.detailNormalMapIndex == data2.detailNormalMapIndex && !(data.detailTiling != data2.detailTiling) && data.shadowLum == data2.shadowLum && data.ambientRate == data2.ambientRate && data.removeTexture == data2.removeTexture && data.useEmission == data2.useEmission;
		}

		// Token: 0x06000CE9 RID: 3305 RVA: 0x0006839F File Offset: 0x0006659F
		public static bool operator !=(MaterialData data, MaterialData data2)
		{
			return !(data == data2);
		}

		// Token: 0x040011E4 RID: 4580
		private const string MAIN_COLOR = "_Color";

		// Token: 0x040011E5 RID: 4581
		private const string AMBIENT_COLOR = "_Ambient";

		// Token: 0x040011E6 RID: 4582
		private const string SPECULAR_COLOR = "_Specular";

		// Token: 0x040011E7 RID: 4583
		private const string EMISSION_COLOR = "_EmissionColor";

		// Token: 0x040011E8 RID: 4584
		private const string MODE = "_Mode";

		// Token: 0x040011E9 RID: 4585
		private const string CUTOFF = "_Cutoff";

		// Token: 0x040011EA RID: 4586
		private const string METALLIC = "_METALLIC";

		// Token: 0x040011EB RID: 4587
		private const string SMOOTHNESS = "_Glossiness";

		// Token: 0x040011EC RID: 4588
		private const string SMOOTHNESS_TEXTURE_CHANNGEL = "_SmoothnessTextureChannel";

		// Token: 0x040011ED RID: 4589
		private const string AMBIENT_RATE = "_AmbientRate";

		// Token: 0x040011EE RID: 4590
		private const string SHADOW_LUM = "_ShadowLum";

		// Token: 0x040011EF RID: 4591
		private const string DETAIL_TEXTURE = "_DetailAlbedoMap";

		// Token: 0x040011F0 RID: 4592
		private const string DETAIL_NORMAL_MAP = "_DetailNormalMap";

		// Token: 0x040011F1 RID: 4593
		public string id;

		// Token: 0x040011F2 RID: 4594
		public string shaderName;

		// Token: 0x040011F3 RID: 4595
		public Color mainColor;

		// Token: 0x040011F4 RID: 4596
		public Color ambientColor;

		// Token: 0x040011F5 RID: 4597
		public Color specularColor;

		// Token: 0x040011F6 RID: 4598
		public Color emissionColor;

		// Token: 0x040011F7 RID: 4599
		public float metallic;

		// Token: 0x040011F8 RID: 4600
		public float smoothness;

		// Token: 0x040011F9 RID: 4601
		public float renderMode;

		// Token: 0x040011FA RID: 4602
		public float alphaCutoff;

		// Token: 0x040011FB RID: 4603
		public int detailNormalMapIndex;

		// Token: 0x040011FC RID: 4604
		public Vector2 detailTiling;

		// Token: 0x040011FD RID: 4605
		public float shadowLum;

		// Token: 0x040011FE RID: 4606
		public float ambientRate;

		// Token: 0x040011FF RID: 4607
		public bool removeTexture;

		// Token: 0x04001200 RID: 4608
		public bool useEmission;
	}
}
